﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace QLVT2
{
    class HoaDonDAL
    {
        public HoaDonDAL() { }
        public DataTable DocDanhSachHoaDon()
        {
            SqlConnection conn = new SqlConnection();
            conn.ConnectionString = "Data Source=(local);Initial Catalog=qlvt; User Id=sa; Password=sa";
            conn.Open();
            SqlCommand cmd = new SqlCommand("select * from hanghoa inner join hoadon on hoadon.mahang=hanghoa.mahang", conn);
            SqlDataReader dr = cmd.ExecuteReader();
            DataTable dt = new DataTable();
            dt.Load(dr);
            return dt;
        }
        public void XoaHoaDon(string sohd)
        {
            SqlConnection conn = new SqlConnection();
            conn.ConnectionString = "Data Source=(local);Initial Catalog=qlvt; User Id=sa; Password=sa";
            conn.Open();
            SqlCommand cmd = new SqlCommand("delete from hoadon where sohd='"+sohd+"'", conn);
            cmd.ExecuteNonQuery();
        }
    }
}
